import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import BMap
df = pd.read_excel('2023年某品牌北京地区销售数据.xlsx')
data = df[['分店名', '销售额（万元）']].values.tolist()
bMap = BMap(init_opts=opts.InitOpts(width='1000px', height='800px', page_title='地理热力图'))
for (a,b,c) in zip(df['分店名'], df['经度'], df['纬度']):
    bMap.add_coordinate(a,b,c)
bMap.add_schema(baidu_ak='PmSUNz1vB2wZMLui6vGozZkMKQb1Q5AC', center=[116.37, 39.91], zoom=11)
bMap.add(series_name='', data_pair=data, type_='heatmap')
bMap.add(series_name='', data_pair=data,type_='scatter', symbol_size=0, label_opts=opts.LabelOpts(color='rgba(0, 0, 0, 0) '))
bMap.set_global_opts(title_opts=opts.TitleOpts(title='2023年某品牌北京各分店销售额地理热力图', pos_left='center'),
                     legend_opts=opts.LegendOpts(is_show=False),visualmap_opts=opts.VisualMapOpts(
        max_=1500, min_=100, pos_top='75%',range_color=['green', 'yellow', 'red']
    ))
bMap.render('例9-2.html')